<%@page import="com.mbbcpa.util.StringUtils"%>
<%@ page import = "java.util.Map" %>
<%@ page import = "java.util.HashMap" %>
<%@ page import = "java.util.ArrayList" %>
<%@ page import = "java.util.Iterator" %>
<%@ page import = "com.mbbcpa.util.Constants" %>

<%@ page import = "com.mbbcpa.security.dao.SecUserDao" %>
<%@ page import = "com.mbbcpa.security.dao.SecAccessDao" %>

<%
String msg = StringUtils.NullSafe((String) request.getAttribute("msg"));
String msg_id = StringUtils.NullSafe((String) request.getAttribute("msg_id"));

String userid = StringUtils.NullSafe((String) request.getAttribute("userid"));
String pass1 = StringUtils.NullSafe((String) request.getAttribute("pass1"));
String pass2 = StringUtils.NullSafe((String) request.getAttribute("pass2"));

boolean showParam = false;
String msgColor = "red";

if (msg_id.equalsIgnoreCase("MSG001") || msg_id.equalsIgnoreCase("MSG002"))
	showParam = true;

if (msg_id.equalsIgnoreCase("MSG999"))
	msgColor = "green";

ArrayList secGroupAccessList = (ArrayList) session.getAttribute(Constants.LOGON_ACCESS_LIST);
SecUserDao oSecUserDao = (SecUserDao) session.getAttribute(Constants.LOGGED_USER);
String sUserName = oSecUserDao.getUserName();
String lastLogonDateTime = (String) session.getAttribute(Constants.LAST_LOGON_DATETIME);

String selected = "sec006";
int iSec001 = 0;
int iSec002 = 0;
int iSec003 = 0;
int iSec004 = 0;
int iSec005 = 0;
int iSec006 = 0;
int iSec007 = 0;
int iSec008 = 0;

for(int i=0;i<secGroupAccessList.size();i++){
	SecAccessDao secaccessDao = (SecAccessDao)secGroupAccessList.get(i);
	String strModuleCode  = secaccessDao.getModuleCode();
	if(strModuleCode.equals("SEC001"))
		iSec001 = 1;
	if(strModuleCode.equals("SEC002"))
		iSec002 = 1;
	if(strModuleCode.equals("SEC003"))
		iSec003 = 1;
	if(strModuleCode.equals("SEC004"))
		iSec004 = 1;
	if(strModuleCode.equals("SEC005"))
		iSec005 = 1;
	if(strModuleCode.equals("SEC006"))
		iSec006 = 1;
	if(strModuleCode.equals("SEC007"))
		iSec007 = 1;
	if(strModuleCode.equals("SEC008"))
		iSec008 = 1;
}


%>
<script type="text/javascript">
	function ResetUser(){
		var frm = document.ResetUserForm;
		if (frm.userid.value == ""){
			alert("User ID is Required.");
			frm.userid.focus();
			return;
		}
		if (frm.pass1.value == ""){
			alert("Password is Required.");
			frm.pass1.focus();
			return;
		}
		if (frm.pass2.value == ""){
			alert("Password Confirmation is Required.");
			frm.pass2.focus();
			return;
		}
		if (!(frm.pass1.value == frm.pass2.value)){
			alert("Passwords are not equal. Please try again.");
			return;
		}
		frm.action = "UserAction.do?dispatch=resetUser";
		frm.submit();
	}
	
</script>
<link href="resource/style.css" rel="stylesheet" type="text/css">
	
	<script type="text/javascript">
	    window.history.forward();
	    function noBack() { window.history.forward(); }
	</script>
<style type="text/css"></style></head>

<body class="home" onload="noBack();" onpageshow="if (event.persisted) noBack();" onunload="">
	<a name="top"></a>
	
<!-- Header -->
<%@ include file="/jsp/common/Header.jsp" %>	
<!-- End Header -->


	<div id="bgWrapper">
		<div id="container">

			<div id="titleBar">
				<ul class="topBar">
					<li class="goBackBt"><a href="<%=request.getContextPath()%>/ShowSecurityHome.do?dispatch=init"></a></li>
					<li>
					  <h1>Reset User</h1></li>
				</ul>
			</div>

			<div id="fullcontent">

<!-- Security Navigation -->
<%@ include file="SecurityNavigation.jsp" %>	
<!-- End SecurityNavigation -->


<div id="contentRightIn">
	<form name="ResetUserForm" method="post">
	<table align="center" class="tblInput" width=90% border="0" rules="cols">
			<thead class="th1">
				<tr>
					<th colspan="2">
						<div class="sectionTableTitle">
							<h4>Security Module - Reset User</h4>
						</div>
					</th>
			</thead>
			<tr>
				<td width="40%" class="center_note">User ID</td>
				<td width="40%" class="center_note"><input class="inputStyle" type="text" name="userid" value="<%=showParam?userid:""%>"></td>
			</tr>
			<tr>
				<td width="40%" class="center_note">User Password</td>
				<td width="40%" class="center_note"><input class="inputStyle" type="password" name="pass1" value="<%=showParam?pass1:""%>"></td>
			</tr>
			<tr>
				<td width="40%" class="center_note">Confirm User Password</td>
				<td width="40%" class="center_note"><input class="inputStyle" type="password" name="pass2" value="<%=showParam?pass2:""%>"></td>
			</tr>
			<tr align="center">
				<td width="40%" class="center_note" colspan="2"><input class="inputButton" type="button" name="reset" value="Submit" onClick="JavaScript:ResetUser();"></td>
			</tr>
	</table>
	<div id="contentMessage">
		<h3 class="<%=msgColor%>"><%=msg%></h3>
	</div>
	
	</form>
</div>
				
</div>

<!-- Footer -->
<%@ include file="/jsp/common/Footer.jsp" %>	
<!-- End Footer -->
</div>
</div>